package com.dingwei.lesyndrome.mvp.presenter;

import com.dingwei.lesyndrome.base.FailsBean;
import com.dingwei.lesyndrome.base.MyBaseBean;
import com.dingwei.lesyndrome.custom.myCallback;
import com.dingwei.lesyndrome.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;
import com.lihao.baselibrary.utils.L;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class ModifyPasswordPresenter extends basePresenter {

    private Contract.ModifyPasswordView modifyPasswordView;

    public ModifyPasswordPresenter(Contract.ModifyPasswordView view) {
        super(view);
        this.modifyPasswordView = view;
    }

    public void modifyPassword(String password, String newpass, String suerpass) {

        RequestParams rp = new RequestParams(URLS.HOST+URLS.SAVE_PWD);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        rp.addBodyParameter("password", password);
        rp.addBodyParameter("newpass", newpass);
        rp.addBodyParameter("suerpass", suerpass);
        x.http().post(rp, new myCallback(BaseActivity.context, MyBaseBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                showToast(baseBean.message);
                modifyPasswordView.modifySuccess();
            }

            @Override
            public void fail(FailsBean baseBean, String result) {
            }
        });

    }

}
